





<!DOCTYPE html>
<html class="writer-html5" lang="zh-CN" >
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>tvm.runtime &mdash; tvm 0.8.dev1982 文档</title>
  

  
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
  <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/gallery.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/css/tlcpack_theme.css" type="text/css" />

  
  
    <link rel="shortcut icon" href="../../../_static/tvm-logo-square.png"/>
  

  
  
  
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script>
        <script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
        <script src="../../../_static/jquery.js"></script>
        <script src="../../../_static/underscore.js"></script>
        <script src="../../../_static/doctools.js"></script>
        <script src="../../../_static/translations.js"></script>
    
    <script type="text/javascript" src="../../../_static/js/theme.js"></script>

    
    <script type="text/javascript" src="../../../_static/js/tlcpack_theme.js"></script>
    <link rel="index" title="索引" href="../../../genindex.html" />
    <link rel="search" title="搜索" href="../../../search.html" />
    <link rel="next" title="tvm.runtime.ndarray" href="ndarray.html" />
    <link rel="prev" title="Python API" href="index.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    
<header class="header">
    <div class="innercontainer">
      <div class="headerInner d-flex justify-content-between align-items-center">
          <div class="headerLogo">
               <a href="https://tvm.apache.org/"><img src=https://tvm.apache.org/assets/images/logo.svg alt="logo"></a>
          </div>

          <div id="headMenu" class="headerNav">
            <button type="button" id="closeHeadMenu" class="navCloseBtn"><img src="../../../_static/img/close-icon.svg" alt="Close"></button>
             <ul class="nav">
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/community>Community</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/download>Download</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/vta>VTA</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/blog>Blog</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/docs>Docs</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvmconf.org>Conference</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://github.com/apache/tvm/>Github</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvmchinese.github.io/declaration_zh_CN.html>About-Translators</a>
                </li>
             </ul>
               <div class="responsivetlcdropdown">
                 <button type="button" class="btn-link">
                   ASF
                 </button>
                 <ul>
                     <li>
                       <a href=https://apache.org/>Apache Homepage</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/licenses/>License</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/foundation/sponsorship.html>Sponsorship</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/security/>Security</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/foundation/thanks.html>Thanks</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/events/current-event>Events</a>
                     </li>
                     <li>
                       <a href=https://www.zhihu.com/column/c_1429578595417563136>Zhihu</a>
                     </li>
                 </ul>
               </div>
          </div>
            <div class="responsiveMenuIcon">
              <button type="button" id="menuBtn" class="btn-menu"><img src="../../../_static/img/menu-icon.svg" alt="Menu Icon"></button>
            </div>

            <div class="tlcDropdown">
              <div class="dropdown">
                <button type="button" class="btn-link dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                  ASF
                </button>
                <div class="dropdown-menu dropdown-menu-right">
                  <ul>
                     <li>
                       <a href=https://apache.org/>Apache Homepage</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/licenses/>License</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/foundation/sponsorship.html>Sponsorship</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/security/>Security</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/foundation/thanks.html>Thanks</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/events/current-event>Events</a>
                     </li>
                     <li>
                       <a href=https://www.zhihu.com/column/c_1429578595417563136>Zhihu</a>
                     </li>
                  </ul>
                </div>
              </div>
          </div>
       </div>
    </div>
 </header>
 
    <nav data-toggle="wy-nav-shift" class="wy-nav-side fixed">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="../../../index.html">
          

          
            
            <img src="../../../_static/tvm-logo-small.png" class="logo" alt="Logo"/>
          
          </a>

          
            
            
                <div class="version">
                  0.8.dev1982
                </div>
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <p class="caption" role="heading"><span class="caption-text">如何开始</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../install/index.html">安装 TVM</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../contribute/index.html">贡献者指南</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">用户引导</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../tutorial/index.html">User Tutorial</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../how_to/index.html">How To Guides</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">开发者引导</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../dev/tutorial/index.html">Developer Tutorial</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../dev/how_to/how_to.html">开发者指南</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">架构指南</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../arch/index.html">Design and Architecture</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">主题引导</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../topic/microtvm/index.html">microTVM：裸机使用TVM</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../topic/vta/index.html">VTA: Versatile Tensor Accelerator</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">参考指南</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../langref/index.html">语言参考</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html">Python API</a><ul class="current">
<li class="toctree-l2 current"><a class="current reference internal" href="#">tvm.runtime</a></li>
<li class="toctree-l2"><a class="reference internal" href="ndarray.html">tvm.runtime.ndarray</a></li>
<li class="toctree-l2"><a class="reference internal" href="error.html">tvm.error</a></li>
<li class="toctree-l2"><a class="reference internal" href="ir.html">tvm.ir</a></li>
<li class="toctree-l2"><a class="reference internal" href="ir.html#module-tvm.instrument">tvm.instrument</a></li>
<li class="toctree-l2"><a class="reference internal" href="ir.html#module-tvm.transform">tvm.transform</a></li>
<li class="toctree-l2"><a class="reference internal" href="target.html">tvm.target</a></li>
<li class="toctree-l2"><a class="reference internal" href="tir.html">tvm.tir</a></li>
<li class="toctree-l2"><a class="reference internal" href="tir.html#module-tvm.tir.transform">tvm.tir.transform</a></li>
<li class="toctree-l2"><a class="reference internal" href="tir.html#tvm-tir-analysis">tvm.tir.analysis</a></li>
<li class="toctree-l2"><a class="reference internal" href="tir.html#module-tvm.tir.stmt_functor">tvm.tir.stmt_functor</a></li>
<li class="toctree-l2"><a class="reference internal" href="te.html">tvm.te</a></li>
<li class="toctree-l2"><a class="reference internal" href="te.html#module-tvm.te.hybrid">tvm.te.hybrid</a></li>
<li class="toctree-l2"><a class="reference internal" href="driver.html">tvm.driver</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/index.html">tvm.relay</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/frontend.html">tvm.relay.frontend</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/nn.html">tvm.relay.nn</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/vision.html">tvm.relay.vision</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/image.html">tvm.relay.image</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/transform.html">tvm.relay.transform</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/analysis.html">tvm.relay.analysis</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/backend.html">tvm.relay.backend</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/dataflow_pattern.html">tvm.relay.dataflow_pattern</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/testing.html">tvm.relay.testing</a></li>
<li class="toctree-l2"><a class="reference internal" href="autotvm.html">tvm.autotvm</a></li>
<li class="toctree-l2"><a class="reference internal" href="auto_scheduler.html">tvm.auto_scheduler</a></li>
<li class="toctree-l2"><a class="reference internal" href="rpc.html">tvm.rpc</a></li>
<li class="toctree-l2"><a class="reference internal" href="micro.html">tvm.micro</a></li>
<li class="toctree-l2"><a class="reference internal" href="contrib.html">tvm.contrib</a></li>
<li class="toctree-l2"><a class="reference internal" href="graph_executor.html">tvm.contrib.graph_executor</a></li>
<li class="toctree-l2"><a class="reference internal" href="topi.html">tvm.topi</a></li>
<li class="toctree-l2"><a class="reference internal" href="vta/index.html">vta</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../links.html">Other APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../publications.html">Publications</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../genindex.html">索引</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
      
      <nav class="wy-nav-top" aria-label="top navigation" data-toggle="wy-nav-top">
        
            <div class="togglemenu">

            </div>
            <div class="nav-content">
              <!-- tvm -->
              Table of content
            </div>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        

          




















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../../../index.html">Docs</a> <span class="br-arrow">></span></li>
        
          <li><a href="index.html">Python API</a> <span class="br-arrow">></span></li>
        
      <li>tvm.runtime</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
            <a href="../../../_sources/reference/api/python/runtime.rst.txt" rel="nofollow"> <img src="../../../_static//img/source.svg" alt="viewsource"/></a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <div class="section" id="module-tvm.runtime">
<span id="tvm-runtime"></span><h1>tvm.runtime<a class="headerlink" href="#module-tvm.runtime" title="永久链接至标题">¶</a></h1>
<p>TVM runtime namespace.</p>
<p><strong>类：</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.runtime.PackedFunc" title="tvm.runtime.PackedFunc"><code class="xref py py-obj docutils literal notranslate"><span class="pre">PackedFunc</span></code></a>(handle, is_global)</p></td>
<td><p>The PackedFunc object used in TVM.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.runtime.Object" title="tvm.runtime.Object"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Object</span></code></a>()</p></td>
<td><p>Base class for all tvm’s runtime objects.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.runtime.ObjectGeneric" title="tvm.runtime.ObjectGeneric"><code class="xref py py-obj docutils literal notranslate"><span class="pre">ObjectGeneric</span></code></a>()</p></td>
<td><p>Base class for all classes that can be converted to object.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.runtime.DataType" title="tvm.runtime.DataType"><code class="xref py py-obj docutils literal notranslate"><span class="pre">DataType</span></code></a>(type_str)</p></td>
<td><p>TVM datatype structure</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.runtime.DataTypeCode" title="tvm.runtime.DataTypeCode"><code class="xref py py-obj docutils literal notranslate"><span class="pre">DataTypeCode</span></code></a>()</p></td>
<td><p>DataType code in DLTensor.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.runtime.Device" title="tvm.runtime.Device"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Device</span></code></a>(device_type, device_id)</p></td>
<td><p>TVM device strucure.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.runtime.Module" title="tvm.runtime.Module"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Module</span></code></a>(handle)</p></td>
<td><p>Runtime Module.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.runtime.Report" title="tvm.runtime.Report"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Report</span></code></a>()</p></td>
<td><p>A container for information gathered during a profiling run.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.runtime.String" title="tvm.runtime.String"><code class="xref py py-obj docutils literal notranslate"><span class="pre">String</span></code></a>(content)</p></td>
<td><p>TVM runtime.String object, represented as a python str.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.runtime.ShapeTuple" title="tvm.runtime.ShapeTuple"><code class="xref py py-obj docutils literal notranslate"><span class="pre">ShapeTuple</span></code></a>(shape)</p></td>
<td><p>TVM runtime ShapeTuple object.</p></td>
</tr>
</tbody>
</table>
<p><strong>函数：</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.runtime.convert_to_object" title="tvm.runtime.convert_to_object"><code class="xref py py-obj docutils literal notranslate"><span class="pre">convert_to_object</span></code></a>(value[, span])</p></td>
<td><p>Convert a Python value to corresponding object type.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.runtime.convert" title="tvm.runtime.convert"><code class="xref py py-obj docutils literal notranslate"><span class="pre">convert</span></code></a>(value[, span])</p></td>
<td><p>Convert value to TVM object or function.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.runtime.const" title="tvm.runtime.const"><code class="xref py py-obj docutils literal notranslate"><span class="pre">const</span></code></a>(value[, dtype, span])</p></td>
<td><p>construct a constant</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.runtime.device" title="tvm.runtime.device"><code class="xref py py-obj docutils literal notranslate"><span class="pre">device</span></code></a>(dev_type[, dev_id])</p></td>
<td><p>Construct a TVM device with given device type and id.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.runtime.cpu" title="tvm.runtime.cpu"><code class="xref py py-obj docutils literal notranslate"><span class="pre">cpu</span></code></a>([dev_id])</p></td>
<td><p>Construct a CPU device</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.runtime.cuda" title="tvm.runtime.cuda"><code class="xref py py-obj docutils literal notranslate"><span class="pre">cuda</span></code></a>([dev_id])</p></td>
<td><p>Construct a CUDA GPU device</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.runtime.gpu" title="tvm.runtime.gpu"><code class="xref py py-obj docutils literal notranslate"><span class="pre">gpu</span></code></a>([dev_id])</p></td>
<td><p>Construct a CUDA GPU device</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.runtime.opencl" title="tvm.runtime.opencl"><code class="xref py py-obj docutils literal notranslate"><span class="pre">opencl</span></code></a>([dev_id])</p></td>
<td><p>Construct a OpenCL device</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.runtime.cl" title="tvm.runtime.cl"><code class="xref py py-obj docutils literal notranslate"><span class="pre">cl</span></code></a>([dev_id])</p></td>
<td><p>Construct a OpenCL device</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.runtime.vulkan" title="tvm.runtime.vulkan"><code class="xref py py-obj docutils literal notranslate"><span class="pre">vulkan</span></code></a>([dev_id])</p></td>
<td><p>Construct a Vulkan device</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.runtime.metal" title="tvm.runtime.metal"><code class="xref py py-obj docutils literal notranslate"><span class="pre">metal</span></code></a>([dev_id])</p></td>
<td><p>Construct a metal device</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.runtime.mtl" title="tvm.runtime.mtl"><code class="xref py py-obj docutils literal notranslate"><span class="pre">mtl</span></code></a>([dev_id])</p></td>
<td><p>Construct a metal device</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.runtime.vpi" title="tvm.runtime.vpi"><code class="xref py py-obj docutils literal notranslate"><span class="pre">vpi</span></code></a>([dev_id])</p></td>
<td><p>Construct a VPI simulated device</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.runtime.rocm" title="tvm.runtime.rocm"><code class="xref py py-obj docutils literal notranslate"><span class="pre">rocm</span></code></a>([dev_id])</p></td>
<td><p>Construct a ROCM device</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.runtime.ext_dev" title="tvm.runtime.ext_dev"><code class="xref py py-obj docutils literal notranslate"><span class="pre">ext_dev</span></code></a>([dev_id])</p></td>
<td><p>Construct a extension device</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.runtime.load_module" title="tvm.runtime.load_module"><code class="xref py py-obj docutils literal notranslate"><span class="pre">load_module</span></code></a>(path[, fmt])</p></td>
<td><p>Load module from file.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.runtime.enabled" title="tvm.runtime.enabled"><code class="xref py py-obj docutils literal notranslate"><span class="pre">enabled</span></code></a>(target)</p></td>
<td><p>Whether module runtime is enabled for target</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.runtime.system_lib" title="tvm.runtime.system_lib"><code class="xref py py-obj docutils literal notranslate"><span class="pre">system_lib</span></code></a>()</p></td>
<td><p>Get system-wide library module singleton.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.runtime.save_param_dict" title="tvm.runtime.save_param_dict"><code class="xref py py-obj docutils literal notranslate"><span class="pre">save_param_dict</span></code></a>(params)</p></td>
<td><p>Save parameter dictionary to binary bytes.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.runtime.load_param_dict" title="tvm.runtime.load_param_dict"><code class="xref py py-obj docutils literal notranslate"><span class="pre">load_param_dict</span></code></a>(param_bytes)</p></td>
<td><p>Load parameter dictionary to binary bytes.</p></td>
</tr>
</tbody>
</table>
<dl class="py class">
<dt class="sig sig-object py" id="tvm.runtime.PackedFunc">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.runtime.</span></span><span class="sig-name descname"><span class="pre">PackedFunc</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">handle</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">is_global</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.runtime.PackedFunc" title="永久链接至目标">¶</a></dt>
<dd><p>The PackedFunc object used in TVM.</p>
<p>Function plays an key role to bridge front and backend in TVM.
Function provide a type-erased interface, you can call function with positional arguments.</p>
<p>The compiled module returns Function.
TVM backend also registers and exposes its API as Functions.</p>
<p>The following are list of common usage scenario of tvm.runtime.PackedFunc.</p>
<ul class="simple">
<li><p>Automatic exposure of C++ API into python</p></li>
<li><p>To call PackedFunc from python side</p></li>
<li><p>To call python callbacks to inspect results in generated code</p></li>
<li><p>Bring python hook into C++ backend</p></li>
</ul>
<div class="admonition seealso">
<p class="admonition-title">参见</p>
<dl class="simple">
<dt><code class="xref py py-obj docutils literal notranslate"><span class="pre">tvm.register_func</span></code></dt><dd><p>How to register global function.</p>
</dd>
<dt><code class="xref py py-obj docutils literal notranslate"><span class="pre">tvm.get_global_func</span></code></dt><dd><p>How to get global function.</p>
</dd>
</dl>
</div>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.runtime.Object">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.runtime.</span></span><span class="sig-name descname"><span class="pre">Object</span></span><a class="headerlink" href="#tvm.runtime.Object" title="永久链接至目标">¶</a></dt>
<dd><p>Base class for all tvm’s runtime objects.</p>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.runtime.ObjectGeneric">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.runtime.</span></span><span class="sig-name descname"><span class="pre">ObjectGeneric</span></span><a class="headerlink" href="#tvm.runtime.ObjectGeneric" title="永久链接至目标">¶</a></dt>
<dd><p>Base class for all classes that can be converted to object.</p>
<p><strong>Methods:</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.runtime.ObjectGeneric.asobject" title="tvm.runtime.ObjectGeneric.asobject"><code class="xref py py-obj docutils literal notranslate"><span class="pre">asobject</span></code></a>()</p></td>
<td><p>Convert value to object</p></td>
</tr>
</tbody>
</table>
<dl class="py method">
<dt class="sig sig-object py" id="tvm.runtime.ObjectGeneric.asobject">
<span class="sig-name descname"><span class="pre">asobject</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.runtime.ObjectGeneric.asobject" title="永久链接至目标">¶</a></dt>
<dd><p>Convert value to object</p>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.runtime.DataType">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.runtime.</span></span><span class="sig-name descname"><span class="pre">DataType</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">type_str</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.runtime.DataType" title="永久链接至目标">¶</a></dt>
<dd><p>TVM datatype structure</p>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.runtime.DataTypeCode">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.runtime.</span></span><span class="sig-name descname"><span class="pre">DataTypeCode</span></span><a class="headerlink" href="#tvm.runtime.DataTypeCode" title="永久链接至目标">¶</a></dt>
<dd><p>DataType code in DLTensor.</p>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.runtime.Device">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.runtime.</span></span><span class="sig-name descname"><span class="pre">Device</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">device_type</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">device_id</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.runtime.Device" title="永久链接至目标">¶</a></dt>
<dd><p>TVM device strucure.</p>
<p>Typically constructed using convenience function
<a class="reference internal" href="#tvm.runtime.device" title="tvm.runtime.device"><code class="xref py py-meth docutils literal notranslate"><span class="pre">tvm.runtime.device()</span></code></a>.</p>
<p>Exposes uniform interface to device-specific APIs such as CUDA or
OpenCL.  Some properties may return None depending on whether an
API exposes that particular property.</p>
<p><strong>Attributes:</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.runtime.Device.exist" title="tvm.runtime.Device.exist"><code class="xref py py-obj docutils literal notranslate"><span class="pre">exist</span></code></a></p></td>
<td><p>Whether this device exists.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.runtime.Device.max_threads_per_block" title="tvm.runtime.Device.max_threads_per_block"><code class="xref py py-obj docutils literal notranslate"><span class="pre">max_threads_per_block</span></code></a></p></td>
<td><p>Maximum number of threads on each block.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.runtime.Device.warp_size" title="tvm.runtime.Device.warp_size"><code class="xref py py-obj docutils literal notranslate"><span class="pre">warp_size</span></code></a></p></td>
<td><p>Number of threads that execute concurrently.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.runtime.Device.max_shared_memory_per_block" title="tvm.runtime.Device.max_shared_memory_per_block"><code class="xref py py-obj docutils literal notranslate"><span class="pre">max_shared_memory_per_block</span></code></a></p></td>
<td><p>Total amount of shared memory per block in bytes.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.runtime.Device.compute_version" title="tvm.runtime.Device.compute_version"><code class="xref py py-obj docutils literal notranslate"><span class="pre">compute_version</span></code></a></p></td>
<td><p>Get compute version number as string.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.runtime.Device.device_name" title="tvm.runtime.Device.device_name"><code class="xref py py-obj docutils literal notranslate"><span class="pre">device_name</span></code></a></p></td>
<td><p>Return the vendor-specific name of device.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.runtime.Device.max_clock_rate" title="tvm.runtime.Device.max_clock_rate"><code class="xref py py-obj docutils literal notranslate"><span class="pre">max_clock_rate</span></code></a></p></td>
<td><p>Return the max clock frequency of device (kHz).</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.runtime.Device.multi_processor_count" title="tvm.runtime.Device.multi_processor_count"><code class="xref py py-obj docutils literal notranslate"><span class="pre">multi_processor_count</span></code></a></p></td>
<td><p>Return the number of compute units in the device.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.runtime.Device.max_thread_dimensions" title="tvm.runtime.Device.max_thread_dimensions"><code class="xref py py-obj docutils literal notranslate"><span class="pre">max_thread_dimensions</span></code></a></p></td>
<td><p>Return the maximum size of each thread axis</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.runtime.Device.api_version" title="tvm.runtime.Device.api_version"><code class="xref py py-obj docutils literal notranslate"><span class="pre">api_version</span></code></a></p></td>
<td><p>Returns version number of the SDK used to compile TVM.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.runtime.Device.driver_version" title="tvm.runtime.Device.driver_version"><code class="xref py py-obj docutils literal notranslate"><span class="pre">driver_version</span></code></a></p></td>
<td><p>Returns version number of the driver</p></td>
</tr>
</tbody>
</table>
<p><strong>Methods:</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.runtime.Device.create_raw_stream" title="tvm.runtime.Device.create_raw_stream"><code class="xref py py-obj docutils literal notranslate"><span class="pre">create_raw_stream</span></code></a>()</p></td>
<td><p>Create a new runtime stream at the context.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.runtime.Device.free_raw_stream" title="tvm.runtime.Device.free_raw_stream"><code class="xref py py-obj docutils literal notranslate"><span class="pre">free_raw_stream</span></code></a>(stream)</p></td>
<td><p>Free a created stream handle.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.runtime.Device.set_raw_stream" title="tvm.runtime.Device.set_raw_stream"><code class="xref py py-obj docutils literal notranslate"><span class="pre">set_raw_stream</span></code></a>(stream)</p></td>
<td><p>Set a created stream handle.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.runtime.Device.sync" title="tvm.runtime.Device.sync"><code class="xref py py-obj docutils literal notranslate"><span class="pre">sync</span></code></a>([stream])</p></td>
<td><p>Synchronize until jobs finished at the context.</p></td>
</tr>
</tbody>
</table>
<dl class="py property">
<dt class="sig sig-object py" id="tvm.runtime.Device.exist">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">exist</span></span><a class="headerlink" href="#tvm.runtime.Device.exist" title="永久链接至目标">¶</a></dt>
<dd><p>Whether this device exists.</p>
<p>Returns True if TVM has support for the device, if the
physical device is present, and the device is accessible
through appropriate drivers (e.g. cuda/vulkan).</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>exist</strong> – True if the device exists</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)">bool</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="tvm.runtime.Device.max_threads_per_block">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">max_threads_per_block</span></span><a class="headerlink" href="#tvm.runtime.Device.max_threads_per_block" title="永久链接至目标">¶</a></dt>
<dd><p>Maximum number of threads on each block.</p>
<p>Returns device value for cuda, metal, rocm, opencl, and vulkan
devices.  Returns remote device value for RPC devices.
Returns None for all other devices.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>max_threads_per_block</strong> – The number of threads on each block</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)">int</a> or <a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(在 Python v3.10)">None</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="tvm.runtime.Device.warp_size">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">warp_size</span></span><a class="headerlink" href="#tvm.runtime.Device.warp_size" title="永久链接至目标">¶</a></dt>
<dd><p>Number of threads that execute concurrently.</p>
<p>Returns device value for for cuda, rocm, and vulkan.  Returns
1 for metal and opencl devices, regardless of the physical
device.  Returns remote device value for RPC devices.  Returns
None for all other devices.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>warp_size</strong> – Number of threads that execute concurrently</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)">int</a> or <a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(在 Python v3.10)">None</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="tvm.runtime.Device.max_shared_memory_per_block">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">max_shared_memory_per_block</span></span><a class="headerlink" href="#tvm.runtime.Device.max_shared_memory_per_block" title="永久链接至目标">¶</a></dt>
<dd><p>Total amount of shared memory per block in bytes.</p>
<p>Returns device value for cuda, rocm, opencl, and vulkan.
Returns remote device value for RPC devices.  Returns None for
all other devices.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>max_shared_memory_per_block</strong> – Total amount of shared memory per block in bytes</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)">int</a> or <a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(在 Python v3.10)">None</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="tvm.runtime.Device.compute_version">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">compute_version</span></span><a class="headerlink" href="#tvm.runtime.Device.compute_version" title="永久链接至目标">¶</a></dt>
<dd><p>Get compute version number as string.</p>
<p>Returns maximum API version (e.g. CUDA/OpenCL/Vulkan)
supported by the device.</p>
<p>Returns device value for cuda, rocm, opencl, and
vulkan. Returns remote device value for RPC devices.  Returns
None for all other devices.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>version</strong> – The version string in <cite>major.minor</cite> format.</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)">str</a> or <a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(在 Python v3.10)">None</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="tvm.runtime.Device.device_name">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">device_name</span></span><a class="headerlink" href="#tvm.runtime.Device.device_name" title="永久链接至目标">¶</a></dt>
<dd><p>Return the vendor-specific name of device.</p>
<p>Returns device value for cuda, rocm, opencl, and vulkan.
Returns remote device value for RPC devices.  Returns None for
all other devices.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>device_name</strong> – The name of the device.</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)">str</a> or <a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(在 Python v3.10)">None</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="tvm.runtime.Device.max_clock_rate">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">max_clock_rate</span></span><a class="headerlink" href="#tvm.runtime.Device.max_clock_rate" title="永久链接至目标">¶</a></dt>
<dd><p>Return the max clock frequency of device (kHz).</p>
<p>Returns device value for cuda, rocm, and opencl.  Returns
remote device value for RPC devices.  Returns None for all
other devices.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>max_clock_rate</strong> – The maximum clock frequency of the device (kHz)</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)">int</a> or <a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(在 Python v3.10)">None</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="tvm.runtime.Device.multi_processor_count">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">multi_processor_count</span></span><a class="headerlink" href="#tvm.runtime.Device.multi_processor_count" title="永久链接至目标">¶</a></dt>
<dd><p>Return the number of compute units in the device.</p>
<p>Returns device value for cuda, rocm, and opencl.  Returns
remote device value for RPC devices.  Returns None for all
other devices.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>multi_processor_count</strong> – Thee number of compute units in the device</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)">int</a> or <a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(在 Python v3.10)">None</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="tvm.runtime.Device.max_thread_dimensions">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">max_thread_dimensions</span></span><a class="headerlink" href="#tvm.runtime.Device.max_thread_dimensions" title="永久链接至目标">¶</a></dt>
<dd><p>Return the maximum size of each thread axis</p>
<p>Returns device value for cuda, rocm, opencl, and vulkan.
Returns remote device value for RPC devices.  Returns None for
all other devices.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>dims</strong> – The maximum length of threadIdx.x, threadIdx.y, threadIdx.z</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p>List of int, or <a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(在 Python v3.10)">None</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="tvm.runtime.Device.api_version">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">api_version</span></span><a class="headerlink" href="#tvm.runtime.Device.api_version" title="永久链接至目标">¶</a></dt>
<dd><p>Returns version number of the SDK used to compile TVM.</p>
<p>For example, CUDA_VERSION for cuda or VK_HEADER_VERSION for
Vulkan.</p>
<p>Returns device value for cuda, rocm, opencl, and vulkan.
Returns remote device value for RPC devices.  Returns None for
all other devices.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>version</strong> – The version of the SDK</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)">int</a> or <a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(在 Python v3.10)">None</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="tvm.runtime.Device.driver_version">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">driver_version</span></span><a class="headerlink" href="#tvm.runtime.Device.driver_version" title="永久链接至目标">¶</a></dt>
<dd><p>Returns version number of the driver</p>
<p>Returns driver vendor’s internal version number.
(e.g. “450.408.256” for nvidia-driver-450)</p>
<p>Returns device value for opencl and vulkan.  Returns remote
device value for RPC devices.  Returns None for all other
devices.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>version</strong> – The version string in <cite>major.minor.patch</cite> format.</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)">str</a> or <a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(在 Python v3.10)">None</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.runtime.Device.create_raw_stream">
<span class="sig-name descname"><span class="pre">create_raw_stream</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.runtime.Device.create_raw_stream" title="永久链接至目标">¶</a></dt>
<dd><p>Create a new runtime stream at the context.</p>
<p>User should free the stream after use.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>stream</strong> – The created runtime stream.</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p>TVMStreamHandle</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.runtime.Device.free_raw_stream">
<span class="sig-name descname"><span class="pre">free_raw_stream</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stream</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.runtime.Device.free_raw_stream" title="永久链接至目标">¶</a></dt>
<dd><p>Free a created stream handle.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>stream</strong> (<em>TVMStreamHandle</em>) – The stream which should to be released.</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.runtime.Device.set_raw_stream">
<span class="sig-name descname"><span class="pre">set_raw_stream</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stream</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.runtime.Device.set_raw_stream" title="永久链接至目标">¶</a></dt>
<dd><p>Set a created stream handle.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>stream</strong> (<em>TVMStreamHandle</em>) – The stream which should to be set to the device.</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.runtime.Device.sync">
<span class="sig-name descname"><span class="pre">sync</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stream</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.runtime.Device.sync" title="永久链接至目标">¶</a></dt>
<dd><p>Synchronize until jobs finished at the context.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>stream</strong> (<em>TVMStreamHandle</em>) – Jobs in this stream should be finished.</p>
</dd>
</dl>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.runtime.Module">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.runtime.</span></span><span class="sig-name descname"><span class="pre">Module</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">handle</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.runtime.Module" title="永久链接至目标">¶</a></dt>
<dd><p>Runtime Module.</p>
<p><strong>Attributes:</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.runtime.Module.entry_func" title="tvm.runtime.Module.entry_func"><code class="xref py py-obj docutils literal notranslate"><span class="pre">entry_func</span></code></a></p></td>
<td><p>Get the entry function</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.runtime.Module.type_key" title="tvm.runtime.Module.type_key"><code class="xref py py-obj docutils literal notranslate"><span class="pre">type_key</span></code></a></p></td>
<td><p>Get type key of the module.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.runtime.Module.imported_modules" title="tvm.runtime.Module.imported_modules"><code class="xref py py-obj docutils literal notranslate"><span class="pre">imported_modules</span></code></a></p></td>
<td><p>Get imported modules</p></td>
</tr>
</tbody>
</table>
<p><strong>Methods:</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.runtime.Module.get_function" title="tvm.runtime.Module.get_function"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_function</span></code></a>(name[, query_imports])</p></td>
<td><p>Get function from the module.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.runtime.Module.import_module" title="tvm.runtime.Module.import_module"><code class="xref py py-obj docutils literal notranslate"><span class="pre">import_module</span></code></a>(module)</p></td>
<td><p>Add module to the import list of current one.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.runtime.Module.get_source" title="tvm.runtime.Module.get_source"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_source</span></code></a>([fmt])</p></td>
<td><p>Get source code from module, if available.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.runtime.Module.save" title="tvm.runtime.Module.save"><code class="xref py py-obj docutils literal notranslate"><span class="pre">save</span></code></a>(file_name[, fmt])</p></td>
<td><p>Save the module to file.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.runtime.Module.time_evaluator" title="tvm.runtime.Module.time_evaluator"><code class="xref py py-obj docutils literal notranslate"><span class="pre">time_evaluator</span></code></a>(func_name, dev[, number, …])</p></td>
<td><p>Get an evaluator that measures time cost of running function.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.runtime.Module.export_library" title="tvm.runtime.Module.export_library"><code class="xref py py-obj docutils literal notranslate"><span class="pre">export_library</span></code></a>(file_name[, fcompile, …])</p></td>
<td><p>Export the module and all imported modules into a single device library.</p></td>
</tr>
</tbody>
</table>
<dl class="py property">
<dt class="sig sig-object py" id="tvm.runtime.Module.entry_func">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">entry_func</span></span><a class="headerlink" href="#tvm.runtime.Module.entry_func" title="永久链接至目标">¶</a></dt>
<dd><p>Get the entry function</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>f</strong> – The entry function if exist</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="#tvm.runtime.PackedFunc" title="tvm.runtime.PackedFunc">tvm.runtime.PackedFunc</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.runtime.Module.get_function">
<span class="sig-name descname"><span class="pre">get_function</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">query_imports</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.runtime.Module.get_function" title="永久链接至目标">¶</a></dt>
<dd><p>Get function from the module.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The name of the function</p></li>
<li><p><strong>query_imports</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)"><em>bool</em></a>) – Whether also query modules imported by this module.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>f</strong> – The result function.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="#tvm.runtime.PackedFunc" title="tvm.runtime.PackedFunc">tvm.runtime.PackedFunc</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.runtime.Module.import_module">
<span class="sig-name descname"><span class="pre">import_module</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">module</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.runtime.Module.import_module" title="永久链接至目标">¶</a></dt>
<dd><p>Add module to the import list of current one.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>module</strong> (<a class="reference internal" href="#tvm.runtime.Module" title="tvm.runtime.Module"><em>tvm.runtime.Module</em></a>) – The other module.</p>
</dd>
</dl>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="tvm.runtime.Module.type_key">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">type_key</span></span><a class="headerlink" href="#tvm.runtime.Module.type_key" title="永久链接至目标">¶</a></dt>
<dd><p>Get type key of the module.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.runtime.Module.get_source">
<span class="sig-name descname"><span class="pre">get_source</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">fmt</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">''</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.runtime.Module.get_source" title="永久链接至目标">¶</a></dt>
<dd><p>Get source code from module, if available.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>fmt</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><em>optional</em>) – The specified format.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>source</strong> – The result source code.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)">str</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="tvm.runtime.Module.imported_modules">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">imported_modules</span></span><a class="headerlink" href="#tvm.runtime.Module.imported_modules" title="永久链接至目标">¶</a></dt>
<dd><p>Get imported modules</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>modules</strong> – The module</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p>list of Module</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.runtime.Module.save">
<span class="sig-name descname"><span class="pre">save</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">file_name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fmt</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">''</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.runtime.Module.save" title="永久链接至目标">¶</a></dt>
<dd><p>Save the module to file.</p>
<p>This do not save the dependent device modules.
See also export_shared</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>file_name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The name of the file.</p></li>
<li><p><strong>fmt</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The format of the file.</p></li>
</ul>
</dd>
</dl>
<div class="admonition seealso">
<p class="admonition-title">参见</p>
<dl class="simple">
<dt><code class="xref py py-obj docutils literal notranslate"><span class="pre">runtime.Module.export_library</span></code></dt><dd><p>export the module to shared library.</p>
</dd>
</dl>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.runtime.Module.time_evaluator">
<span class="sig-name descname"><span class="pre">time_evaluator</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">func_name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dev</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">number</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">10</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">repeat</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">min_repeat_ms</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">f_preproc</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">''</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.runtime.Module.time_evaluator" title="永久链接至目标">¶</a></dt>
<dd><p>Get an evaluator that measures time cost of running function.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>func_name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The name of the function in the module.</p></li>
<li><p><strong>dev</strong> (<a class="reference internal" href="#tvm.runtime.Device" title="tvm.runtime.Device"><em>Device</em></a>) – The device we should run this function on.</p></li>
<li><p><strong>number</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – The number of times to run this function for taking average.
We call these runs as one <cite>repeat</cite> of measurement.</p></li>
<li><p><strong>repeat</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>, </em><em>optional</em>) – The number of times to repeat the measurement.
In total, the function will be invoked (1 + number x repeat) times,
where the first one is warm up and will be discarded.
The returned result contains <cite>repeat</cite> costs,
each of which is an average of <cite>number</cite> costs.</p></li>
<li><p><strong>min_repeat_ms</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>, </em><em>optional</em>) – The minimum duration of one <cite>repeat</cite> in milliseconds.
By default, one <cite>repeat</cite> contains <cite>number</cite> runs. If this parameter is set,
the parameters <cite>number</cite> will be dynamically adjusted to meet the
minimum duration requirement of one <cite>repeat</cite>.
i.e., When the run time of one <cite>repeat</cite> falls below this time, the <cite>number</cite> parameter
will be automatically increased.</p></li>
<li><p><strong>f_preproc</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><em>optional</em>) – The preprocess function name we want to execute before executing the time evaluator.</p></li>
</ul>
</dd>
</dl>
<div class="admonition note">
<p class="admonition-title">注解</p>
<p>The function will be invoked  (1 + number x repeat) times,
with the first call discarded in case there is lazy initialization.</p>
</div>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>ftimer</strong> – The function that takes same argument as func and returns a BenchmarkResult.
The ProfileResult reports <cite>repeat</cite> time costs in seconds.</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p>function</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.runtime.Module.export_library">
<span class="sig-name descname"><span class="pre">export_library</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">file_name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fcompile</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">addons</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">workspace_dir</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.runtime.Module.export_library" title="永久链接至目标">¶</a></dt>
<dd><p>Export the module and all imported modules into a single device library.</p>
<p>This function only works on host LLVM modules, other runtime::Module
subclasses will work with this API but they must support implement
the save and load mechanisms of modules completely including saving
from streams and files. This will pack your non-shared library module
into a single shared library which can later be loaded by TVM.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>file_name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The name of the shared library.</p></li>
<li><p><strong>fcompile</strong> (<em>function</em><em>(</em><em>target</em><em>, </em><em>file_list</em><em>, </em><em>kwargs</em><em>)</em><em>, </em><em>optional</em>) – <p>The compilation function to use create the final library object during
export.</p>
<p>For example, when fcompile=_cc.create_shared, or when it is not supplied but
module is “llvm,” this is used to link all produced artifacts
into a final dynamic library.</p>
<p>This behavior is controlled by the type of object exported.
If fcompile has attribute object_format, will compile host library
to that format. Otherwise, will use default format “o”.</p>
</p></li>
<li><p><strong>workspace_dir</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><em>optional</em>) – The path of the directory used to create the intermediate
artifacts when exporting the module.
If this is not provided a temporary dir will be created.</p></li>
<li><p><strong>kwargs</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#dict" title="(在 Python v3.10)"><em>dict</em></a><em>, </em><em>optional</em>) – Additional arguments passed to fcompile</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>result of fcompile()</strong> – If the compilation function returns an artifact it would be returned via
export_library, if any.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>unknown, optional</p>
</dd>
</dl>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.runtime.Report">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.runtime.</span></span><span class="sig-name descname"><span class="pre">Report</span></span><a class="headerlink" href="#tvm.runtime.Report" title="永久链接至目标">¶</a></dt>
<dd><p>A container for information gathered during a profiling run.</p>
<dl class="py attribute">
<dt class="sig sig-object py" id="tvm.runtime.Report.calls">
<span class="sig-name descname"><span class="pre">calls</span></span><a class="headerlink" href="#tvm.runtime.Report.calls" title="永久链接至目标">¶</a></dt>
<dd><p>Per-call profiling metrics (function name, runtime, device, …).</p>
<dl class="field-list simple">
<dt class="field-odd">Type</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.Array" title="tvm.ir.Array">Array</a>[<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.Dict" title="tvm.relay.dataflow_pattern.Dict">Dict</a>[<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)">str</a>, <a class="reference internal" href="#tvm.runtime.Object" title="tvm.runtime.Object">Object</a>]]</p>
</dd>
</dl>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="tvm.runtime.Report.device_metrics">
<span class="sig-name descname"><span class="pre">device_metrics</span></span><a class="headerlink" href="#tvm.runtime.Report.device_metrics" title="永久链接至目标">¶</a></dt>
<dd><p>Per-device metrics collected over the entire run.</p>
<dl class="field-list simple">
<dt class="field-odd">Type</dt>
<dd class="field-odd"><p><a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.Dict" title="tvm.relay.dataflow_pattern.Dict">Dict</a>[<a class="reference internal" href="#tvm.runtime.Device" title="tvm.runtime.Device">Device</a>, <a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.Dict" title="tvm.relay.dataflow_pattern.Dict">Dict</a>[<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)">str</a>, <a class="reference internal" href="#tvm.runtime.Object" title="tvm.runtime.Object">Object</a>]]</p>
</dd>
</dl>
</dd></dl>

<p><strong>Methods:</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.runtime.Report.csv" title="tvm.runtime.Report.csv"><code class="xref py py-obj docutils literal notranslate"><span class="pre">csv</span></code></a>()</p></td>
<td><p>Convert this profiling report into CSV format.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.runtime.Report.json" title="tvm.runtime.Report.json"><code class="xref py py-obj docutils literal notranslate"><span class="pre">json</span></code></a>()</p></td>
<td><p>Convert this profiling report into JSON format.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.runtime.Report.from_json" title="tvm.runtime.Report.from_json"><code class="xref py py-obj docutils literal notranslate"><span class="pre">from_json</span></code></a>(s)</p></td>
<td><p>Deserialize a report from JSON.</p></td>
</tr>
</tbody>
</table>
<dl class="py method">
<dt class="sig sig-object py" id="tvm.runtime.Report.csv">
<span class="sig-name descname"><span class="pre">csv</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.runtime.Report.csv" title="永久链接至目标">¶</a></dt>
<dd><p>Convert this profiling report into CSV format.</p>
<p>This only includes calls and not overall metrics.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>csv</strong> – <cite>calls</cite> in CSV format.</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)">str</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.runtime.Report.json">
<span class="sig-name descname"><span class="pre">json</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.runtime.Report.json" title="永久链接至目标">¶</a></dt>
<dd><p>Convert this profiling report into JSON format.</p>
<p>Example output:</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>json</strong> – Formatted JSON</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)">str</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.runtime.Report.from_json">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">from_json</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">s</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.runtime.Report.from_json" title="永久链接至目标">¶</a></dt>
<dd><p>Deserialize a report from JSON.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>s</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – Report serialize via <a class="reference internal" href="#tvm.runtime.Report.json" title="tvm.runtime.Report.json"><code class="xref py py-meth docutils literal notranslate"><span class="pre">json()</span></code></a>.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>report</strong> – The deserialized report.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="#tvm.runtime.Report" title="tvm.runtime.Report">Report</a></p>
</dd>
</dl>
</dd></dl>

</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.runtime.convert_to_object">
<span class="sig-prename descclassname"><span class="pre">tvm.runtime.</span></span><span class="sig-name descname"><span class="pre">convert_to_object</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.runtime.convert_to_object" title="永久链接至目标">¶</a></dt>
<dd><p>Convert a Python value to corresponding object type.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>value</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The value to be inspected.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>obj</strong> – The corresponding object value.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="#tvm.runtime.Object" title="tvm.runtime.Object">Object</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.runtime.convert">
<span class="sig-prename descclassname"><span class="pre">tvm.runtime.</span></span><span class="sig-name descname"><span class="pre">convert</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.runtime.convert" title="永久链接至目标">¶</a></dt>
<dd><p>Convert value to TVM object or function.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>value</strong> (<em>python value</em>) – </p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this statement in the source code.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>tvm_val</strong> – Converted value in TVM</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="#tvm.runtime.Object" title="tvm.runtime.Object">Object</a> or Function</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.runtime.const">
<span class="sig-prename descclassname"><span class="pre">tvm.runtime.</span></span><span class="sig-name descname"><span class="pre">const</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dtype</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.runtime.const" title="永久链接至目标">¶</a></dt>
<dd><p>construct a constant</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>value</strong> (<em>number</em>) – The content of the constant number.</p></li>
<li><p><strong>dtype</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em> or </em><a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(在 Python v3.10)"><em>None</em></a><em>, </em><em>optional</em>) – The data type.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of the constant value in the source.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>const_val</strong> – The result expression.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>tvm.Expr</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.runtime.device">
<span class="sig-prename descclassname"><span class="pre">tvm.runtime.</span></span><span class="sig-name descname"><span class="pre">device</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dev_type</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dev_id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.runtime.device" title="永久链接至目标">¶</a></dt>
<dd><p>Construct a TVM device with given device type and id.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>dev_type</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em> or </em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The device type mask or name of the device.</p></li>
<li><p><strong>dev_id</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>, </em><em>optional</em>) – The integer device id</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>dev</strong> – The corresponding device.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="#tvm.runtime.Device" title="tvm.runtime.Device">tvm.runtime.Device</a></p>
</dd>
</dl>
<p class="rubric">实际案例</p>
<p>Device can be used to create reflection of device by
string representation of the device type.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">assert</span> <span class="n">tvm</span><span class="o">.</span><span class="n">device</span><span class="p">(</span><span class="s2">&quot;cpu&quot;</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> <span class="o">==</span> <span class="n">tvm</span><span class="o">.</span><span class="n">cpu</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
<span class="k">assert</span> <span class="n">tvm</span><span class="o">.</span><span class="n">device</span><span class="p">(</span><span class="s2">&quot;cuda&quot;</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="o">==</span> <span class="n">tvm</span><span class="o">.</span><span class="n">cuda</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.runtime.cpu">
<span class="sig-prename descclassname"><span class="pre">tvm.runtime.</span></span><span class="sig-name descname"><span class="pre">cpu</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dev_id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.runtime.cpu" title="永久链接至目标">¶</a></dt>
<dd><p>Construct a CPU device</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>dev_id</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>, </em><em>optional</em>) – The integer device id</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>dev</strong> – The created device</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="#tvm.runtime.Device" title="tvm.runtime.Device">Device</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.runtime.cuda">
<span class="sig-prename descclassname"><span class="pre">tvm.runtime.</span></span><span class="sig-name descname"><span class="pre">cuda</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dev_id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.runtime.cuda" title="永久链接至目标">¶</a></dt>
<dd><p>Construct a CUDA GPU device</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>dev_id</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>, </em><em>optional</em>) – The integer device id</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>dev</strong> – The created device</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="#tvm.runtime.Device" title="tvm.runtime.Device">Device</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.runtime.gpu">
<span class="sig-prename descclassname"><span class="pre">tvm.runtime.</span></span><span class="sig-name descname"><span class="pre">gpu</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dev_id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.runtime.gpu" title="永久链接至目标">¶</a></dt>
<dd><p>Construct a CUDA GPU device</p>
<blockquote>
<div><p>deprecated:: 0.9.0
Use <code class="xref py py-func docutils literal notranslate"><span class="pre">tvm.cuda()</span></code> instead.</p>
</div></blockquote>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>dev_id</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>, </em><em>optional</em>) – The integer device id</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>dev</strong> – The created device</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="#tvm.runtime.Device" title="tvm.runtime.Device">Device</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.runtime.opencl">
<span class="sig-prename descclassname"><span class="pre">tvm.runtime.</span></span><span class="sig-name descname"><span class="pre">opencl</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dev_id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.runtime.opencl" title="永久链接至目标">¶</a></dt>
<dd><p>Construct a OpenCL device</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>dev_id</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>, </em><em>optional</em>) – The integer device id</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>dev</strong> – The created device</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="#tvm.runtime.Device" title="tvm.runtime.Device">Device</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.runtime.cl">
<span class="sig-prename descclassname"><span class="pre">tvm.runtime.</span></span><span class="sig-name descname"><span class="pre">cl</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dev_id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.runtime.cl" title="永久链接至目标">¶</a></dt>
<dd><p>Construct a OpenCL device</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>dev_id</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>, </em><em>optional</em>) – The integer device id</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>dev</strong> – The created device</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="#tvm.runtime.Device" title="tvm.runtime.Device">Device</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.runtime.vulkan">
<span class="sig-prename descclassname"><span class="pre">tvm.runtime.</span></span><span class="sig-name descname"><span class="pre">vulkan</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dev_id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.runtime.vulkan" title="永久链接至目标">¶</a></dt>
<dd><p>Construct a Vulkan device</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>dev_id</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>, </em><em>optional</em>) – The integer device id</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>dev</strong> – The created device</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="#tvm.runtime.Device" title="tvm.runtime.Device">Device</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.runtime.metal">
<span class="sig-prename descclassname"><span class="pre">tvm.runtime.</span></span><span class="sig-name descname"><span class="pre">metal</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dev_id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.runtime.metal" title="永久链接至目标">¶</a></dt>
<dd><p>Construct a metal device</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>dev_id</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>, </em><em>optional</em>) – The integer device id</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>dev</strong> – The created device</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="#tvm.runtime.Device" title="tvm.runtime.Device">Device</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.runtime.mtl">
<span class="sig-prename descclassname"><span class="pre">tvm.runtime.</span></span><span class="sig-name descname"><span class="pre">mtl</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dev_id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.runtime.mtl" title="永久链接至目标">¶</a></dt>
<dd><p>Construct a metal device</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>dev_id</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>, </em><em>optional</em>) – The integer device id</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>dev</strong> – The created device</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="#tvm.runtime.Device" title="tvm.runtime.Device">Device</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.runtime.vpi">
<span class="sig-prename descclassname"><span class="pre">tvm.runtime.</span></span><span class="sig-name descname"><span class="pre">vpi</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dev_id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.runtime.vpi" title="永久链接至目标">¶</a></dt>
<dd><p>Construct a VPI simulated device</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>dev_id</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>, </em><em>optional</em>) – The integer device id</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>dev</strong> – The created device</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="#tvm.runtime.Device" title="tvm.runtime.Device">Device</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.runtime.rocm">
<span class="sig-prename descclassname"><span class="pre">tvm.runtime.</span></span><span class="sig-name descname"><span class="pre">rocm</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dev_id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.runtime.rocm" title="永久链接至目标">¶</a></dt>
<dd><p>Construct a ROCM device</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>dev_id</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>, </em><em>optional</em>) – The integer device id</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>dev</strong> – The created device</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="#tvm.runtime.Device" title="tvm.runtime.Device">Device</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.runtime.ext_dev">
<span class="sig-prename descclassname"><span class="pre">tvm.runtime.</span></span><span class="sig-name descname"><span class="pre">ext_dev</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dev_id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.runtime.ext_dev" title="永久链接至目标">¶</a></dt>
<dd><p>Construct a extension device</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>dev_id</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>, </em><em>optional</em>) – The integer device id</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>dev</strong> – The created device</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="#tvm.runtime.Device" title="tvm.runtime.Device">Device</a></p>
</dd>
</dl>
<div class="admonition note">
<p class="admonition-title">注解</p>
<p>This API is reserved for quick testing of new
device by plugin device API as ext_dev.</p>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.runtime.load_module">
<span class="sig-prename descclassname"><span class="pre">tvm.runtime.</span></span><span class="sig-name descname"><span class="pre">load_module</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">path</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fmt</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">''</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.runtime.load_module" title="永久链接至目标">¶</a></dt>
<dd><p>Load module from file.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>path</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The path to the module file.</p></li>
<li><p><strong>fmt</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><em>optional</em>) – The format of the file, if not specified
it will be inferred from suffix of the file.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>module</strong> – The loaded module</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="#tvm.runtime.Module" title="tvm.runtime.Module">runtime.Module</a></p>
</dd>
</dl>
<div class="admonition note">
<p class="admonition-title">注解</p>
<p>This function will automatically call
cc.create_shared if the path is in format .o or .tar</p>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.runtime.enabled">
<span class="sig-prename descclassname"><span class="pre">tvm.runtime.</span></span><span class="sig-name descname"><span class="pre">enabled</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">target</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.runtime.enabled" title="永久链接至目标">¶</a></dt>
<dd><p>Whether module runtime is enabled for target</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>target</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The target device type.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>enabled</strong> – Whether runtime is enabled.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)">bool</a></p>
</dd>
</dl>
<p class="rubric">实际案例</p>
<p>The following code checks if gpu is enabled.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">tvm</span><span class="o">.</span><span class="n">runtime</span><span class="o">.</span><span class="n">enabled</span><span class="p">(</span><span class="s2">&quot;gpu&quot;</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.runtime.system_lib">
<span class="sig-prename descclassname"><span class="pre">tvm.runtime.</span></span><span class="sig-name descname"><span class="pre">system_lib</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.runtime.system_lib" title="永久链接至目标">¶</a></dt>
<dd><p>Get system-wide library module singleton.</p>
<p>System lib is a global module that contains self register functions in startup.
Unlike normal dso modules which need to be loaded explicitly.
It is useful in environments where dynamic loading api like dlopen is banned.</p>
<p>To build system lib function, simply specify target option <code class="docutils literal notranslate"><span class="pre">`llvm</span> <span class="pre">--system-lib`</span></code>
The system lib will be available as long as the result code is linked by the program.</p>
<p>The system lib is intended to be linked and loaded during the entire life-cyle of the program.
If you want dynamic loading features, use dso modules instead.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>module</strong> – The system-wide library module.</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="#tvm.runtime.Module" title="tvm.runtime.Module">runtime.Module</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.runtime.String">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.runtime.</span></span><span class="sig-name descname"><span class="pre">String</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">content</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.runtime.String" title="永久链接至目标">¶</a></dt>
<dd><p>TVM runtime.String object, represented as a python str.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>content</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The content string used to construct the object.</p>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.runtime.ShapeTuple">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.runtime.</span></span><span class="sig-name descname"><span class="pre">ShapeTuple</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">shape</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.runtime.ShapeTuple" title="永久链接至目标">¶</a></dt>
<dd><p>TVM runtime ShapeTuple object.
:param shape: The shape list used to construct the object.
:type shape: list[int]</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.runtime.save_param_dict">
<span class="sig-prename descclassname"><span class="pre">tvm.runtime.</span></span><span class="sig-name descname"><span class="pre">save_param_dict</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">params</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.runtime.save_param_dict" title="永久链接至目标">¶</a></dt>
<dd><p>Save parameter dictionary to binary bytes.</p>
<p>The result binary bytes can be loaded by the
GraphModule with API “load_params”.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>params</strong> (<em>dict of str to NDArray</em>) – The parameter dictionary.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>param_bytes</strong> – Serialized parameters.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#bytearray" title="(在 Python v3.10)">bytearray</a></p>
</dd>
</dl>
<p class="rubric">实际案例</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># set up the parameter dict</span>
<span class="n">params</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;param0&quot;</span><span class="p">:</span> <span class="n">arr0</span><span class="p">,</span> <span class="s2">&quot;param1&quot;</span><span class="p">:</span> <span class="n">arr1</span><span class="p">}</span>
<span class="c1"># save the parameters as byte array</span>
<span class="n">param_bytes</span> <span class="o">=</span> <span class="n">tvm</span><span class="o">.</span><span class="n">runtime</span><span class="o">.</span><span class="n">save_param_dict</span><span class="p">(</span><span class="n">params</span><span class="p">)</span>
<span class="c1"># We can serialize the param_bytes and load it back later.</span>
<span class="c1"># Pass in byte array to module to directly set parameters</span>
<span class="n">tvm</span><span class="o">.</span><span class="n">runtime</span><span class="o">.</span><span class="n">load_param_dict</span><span class="p">(</span><span class="n">param_bytes</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.runtime.load_param_dict">
<span class="sig-prename descclassname"><span class="pre">tvm.runtime.</span></span><span class="sig-name descname"><span class="pre">load_param_dict</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">param_bytes</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.runtime.load_param_dict" title="永久链接至目标">¶</a></dt>
<dd><p>Load parameter dictionary to binary bytes.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>param_bytes</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#bytearray" title="(在 Python v3.10)"><em>bytearray</em></a>) – Serialized parameters.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>params</strong> – The parameter dictionary.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>dict of str to NDArray</p>
</dd>
</dl>
</dd></dl>

</div>


           </div>
           
          </div>
          

<footer>

    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="ndarray.html" class="btn btn-neutral float-right" title="tvm.runtime.ndarray" accesskey="n" rel="next">下一个 <span class="fa fa-arrow-circle-right"></span></a>
      
      
        <a href="index.html" class="btn btn-neutral float-left" title="Python API" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> 上一个</a>
      
    </div>

<div id="button" class="backtop"><img src="../../../_static//img/right.svg" alt="backtop"/> </div>
<section class="footerSec">
    <div class="footerHeader">
      <ul class="d-flex align-md-items-center justify-content-between flex-column flex-md-row">
        <li class="copywrite d-flex align-items-center">
          <h5 id="copy-right-info">© 2020 Apache Software Foundation | All right reserved</h5>
        </li>
      </ul>

    </div>

    <ul>
      <li class="footernote">Copyright © 2020 The Apache Software Foundation. Apache TVM, Apache, the Apache feather, and the Apache TVM project logo are either trademarks or registered trademarks of the Apache Software Foundation.</li>
    </ul>

</section>
</footer>
        </div>
      </div>

    </section>

  </div>
  

    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>

  </body>
  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
    <!-- Theme Analytics -->
    <script>
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

    ga('create', 'UA-75982049-2', 'auto');
    ga('send', 'pageview');
    </script>

    
   

</body>
</html>